<%@page import="org.json.simple.JSONArray"%>
<%@page import="org.json.simple.JSONValue"%>
<%@page import="org.json.simple.JSONObject"%>
<%@page import="org.tempuri.VendasLocator"%>
<%@page import="org.tempuri.VendasSoap"%>
<%@page import="org.tempuri.Vendas"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
	<table>
		<tr>
			<td>Categoria</td>
		</tr>
		<%
			Vendas servico = new VendasLocator();
			VendasSoap soap = servico.getVendasSoap();
			
			int idCategoriaPai = 0;
			String q = request.getParameter("q");
			if(q != null && !q.isEmpty()){
				idCategoriaPai = Integer.parseInt(q);
			}
			
			String categorias = soap.listarCategoriaProduto(idCategoriaPai);
			JSONArray categoriasJson = (JSONArray) JSONValue.parse(categorias);
			for(int i=0;i<categoriasJson.size();i++){
		%> 
		<tr>
			<td><%=((JSONObject)categoriasJson.get(i)).get("Descricao")%></td>
		</tr> 
		<%	} %>
	</table>
</body>
</html>